import {
  SET_USER,
  SET_LOGIN,
  SET_AUTH,
  
  SET_GLOBAL
} from '../constants/counter'

const INITIAL_STATE = {
  isLogin: false,
  isAuth: false
}

export function userinfo(state = INITIAL_STATE, action) {
  switch (action.type) {
    case SET_USER:
      return Object.assign(state, action.user)
    case SET_LOGIN:
      return { ...state, isLogin: action.isLogin }
    case SET_AUTH:
      return { ...state, isAuth: action.isAuth }
    default:
      return state;
  }
}

const INIT_GLOBALDATA = {
  navHeight: '',
  navTop: ''
}
export function globalData(state = INIT_GLOBALDATA, action) {
  switch (action.type) {
    case SET_GLOBAL:
      console.log(action, 'action');
      return {...state, ...action.payload}  
    default:
      break;
  }
  return state
}